package com.shy;


import com.shy.config.common.JWTConstants;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.boot.CommandLineRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.cache.annotation.EnableCaching;
import org.springframework.context.annotation.Bean;
import org.springframework.scheduling.annotation.EnableAsync;
import org.springframework.security.crypto.bcrypt.BCryptPasswordEncoder;
import org.springframework.security.crypto.password.PasswordEncoder;

@SpringBootApplication
@EnableAsync// 开启异步调用
@MapperScan(basePackages = "com.shy.mapper")
@EnableCaching// 开启注解缓存


public class DlykApplication implements CommandLineRunner {

    @Value("${jwt.secret}")
    private String JwtSecret;

    public static void main(String[] args) {
        SpringApplication.run(DlykApplication.class, args);
    }

    @Bean
    public PasswordEncoder passwordEncoder() {
        return new BCryptPasswordEncoder();
    }

    /**
     * 项目启动时执行
     *
     * @param args
     * @throws Exception
     */
    @Override
    public void run(String... args) throws Exception {
        JWTConstants.JWT_SECRET = JwtSecret;
    }
}
